Skip to content

feat(cartridges): add k9iser-mcp — central K9 contract regeneration - #73

Merged
hyperpolymath merged 10 commits into
mainfrom
feat/k9iser-mcp-cartridge
May 18, 2026
Merged

feat(cartridges): add k9iser-mcp — central K9 contract regeneration#73
hyperpolymath merged 10 commits into
mainfrom
feat/k9iser-mcp-cartridge

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented May 17, 2026

Copy link
Copy Markdown
Owner

Reference implementation of the -iser regeneration-cartridge pattern, now hardened to BoJ standards.

Scope (expanded)

  • k9iser-mcp cartridge mirroring ssg-mcp (cartridge.json, mod.js, Idris2 ABI, Zig FFI, panels).
  • Unified transaction-gated adapter: ONE internal/loopback listener, protocol-routed REST+SSE+GraphQL+gRPC-compat → SINGLE dispatch → one Zig ABI. Replaces the ssg-era 3-parallel-port anti-pattern. Gate runs before every dispatch, mirroring the Idris2 exposureSatisfied contract — no gatekeeperless path. Internal-only, behind http-capability-gateway per ADR-0004.
  • boj-rest SSE: POST /cartridge/:name/sse on the same single Cowboy listener, same trust-gated dispatch, text/event-stream.
  • Doc reconciliation: elixir/README.adoc, mcp-bridge/api-clients.js, OPERATOR-QUICKSTART.md corrected to the verified runtime + ADR-0004 tiered model (they wrongly said "skeleton/501/pending rewrite").

Verification

  • Elixir suite 177/177 (incl. 2 SSE tests); live /invoke + /sse proven through the Zig .so.
  • Zig: ffi 16/16, unified adapter 5/5 (incl. exposure-gate truth table mirroring the Idris2 contract).
  • idris2 --check K9iserMcp/SafeK9iser.idr passes.

Not in scope (tracked)

http-capability-gateway production-wiring (ADR-0004 tier-2; ~8–12wk programme) and the iseriser-scaffold rollout (standards epic). The runtime stays internal/loopback until the gateway lands.

Refs hyperpolymath/k9iser#8.

🤖 Generated with Claude Code

hyperpolymath and others added 3 commits May 17, 2026 04:16
Reference implementation of the -iser regeneration-cartridge pattern.
Wraps the k9iser generator so generated/k9iser/*.k9 are regenerated
centrally on trigger instead of run ad hoc + hand-committed (the drift
that broke Dogfood Gate estate-wide — k9iser#8, idaptik#77).

Mirrors ssg-mcp structure: cartridge.json (5 tools, ADR-0006 ffi
symbols), mod.js MCP bridge (backend :7743), abi/ Idris2 pipeline state
machine + safety GADT (no apply-without-validate, no validate-without-
generate), ffi/ Zig C-ABI + boj_cartridge_invoke dispatch, three-
protocol adapter, Panll panels.

Verified: ffi `zig build test` 16/16 pass (state machine + invariants +
ADR-0006 dispatch); adapter builds on Zig 0.15.2 (adapter/build.zig
uses the modern root_module API — the ssg-mcp exemplar's is stale).

Grade D Alpha: invoke returns shaped stubs; live path additionally needs
the backend service + the BoJ REST runtime (pending Elixir rewrite),
exactly as ssg-mcp/boj-build.yml are today.

Refs hyperpolymath/k9iser#8.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… contract

- adapter: ONE internal/loopback listener, protocol-routed (REST + SSE +
  GraphQL + gRPC-compat) into a SINGLE dispatch → the one Zig ABI.
  Replaces the ssg-era 3-parallel-port pattern (the anti-pattern).
- Transaction gate runs before every dispatch (exposureGate), mirroring
  the new Idris2 SafeK9iser.exposureSatisfied contract — no gatekeeperless
  path to the ABI (estate interface-safety policy). Explicitly
  internal-only, behind the http-capability-gateway per ADR-0004.
- abi: add Exposure / requiredExposure / exposureSatisfied +
  k9_exposure_satisfied FFI. `idris2 --check` passes.
- ffi: mark boj_cartridge_invoke `pub` so the unified adapter calls the
  one ABI directly (consistent with the other 4 ADR-0006 symbols).
- adapter/build.zig: add test step. zig: ffi 16/16 + adapter 5/5 pass.

Refs hyperpolymath/k9iser#8.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- router: add POST /cartridge/:name/sse — same trust-gated dispatch as
  /invoke, streamed as text/event-stream (open→result|error→done) on the
  SAME single Cowboy listener (not a parallel server). +2 tests; full
  suite 177/0.
- Reconcile docs that contradicted the verified runtime:
  * elixir/README.adoc: "skeleton / invoke 501 / Phase 2 pending" →
    REST/SSE wired through the unified Zig ABI, trust-gated; Phase 2
    DONE; Phase 3 gateway = accepted-but-tracked (ADR-0004, ~8–12wk).
  * mcp-bridge/api-clients.js: "not deployed (pending Elixir rewrite)" →
    accurate "core implemented; unreachable here / gateway not wired".
  * OPERATOR-QUICKSTART.md: 7700/7701/7702 are facets of one unified
    gated core; sole governed public ingress = http-capability-gateway
    (ADR-0004), cartridge adapters internal-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 28 issues detected

Severity Count
🔴 Critical 17
🟠 High 4
🟡 Medium 7

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Stale AI session file -- delete",
    "type": "stale",
    "file": "GEMINI.md",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "medium"
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/sanctify-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/academic-workflow-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/fireflag-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/ephapax-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/bofig-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/hesiod-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath
hyperpolymath enabled auto-merge (squash) May 18, 2026 07:44
The inline `python3 -c` block placed Python source at column 1 inside a
`run: |` block scalar. YAML terminated the scalar at the first under-
indented line, so Dogfood Gate failed at startup (0s, no jobs) on every
branch incl. main. Since 'Dogfood Gate' is a required check, no PR in the
repo could merge. Moved the validator to .github/scripts/ and call it.

Refs #73

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath

Copy link
Copy Markdown
Owner Author

CI root-cause + fix (Refs #73)

Pushed 891b162 to this branch fixing a real merge blocker independent of this PR's feature work:

  • dogfood-gate.yml had an inline python3 -c " block with Python source at column 1 inside a run: | block scalar. YAML terminated the scalar early → the workflow failed at startup (0s, no jobs), surfacing as .github/workflows/dogfood-gate.yml instead of Dogfood Gate in run lists.
  • Dogfood Gate is a required status check (alongside Hypatia Neurosymbolic Analysis, OpenSSF Scorecard), so this silently blocked every PR in the repo on every branch incl. main.
  • Fix: extracted the validator to .github/scripts/validate-eclexiaiser.py and call it. Verified locally: dogfood-gate.yml now parses (PyYAML), script py_compiles and smoke-tests green. Fixes main on squash-merge.

Remaining blocker (not repo-local): GitHub Actions is runner-starved estate-wide — 49 runs queued, 0 in-progress repo-wide. The required checks physically cannot execute until that clears. Holding the squash-merge until checks actually run and pass (no --admin past unrun required checks).

This pattern is templated, so other consumer repos likely carry the same silent Dogfood Gate break — recommend a templated sweep at source.

hyperpolymath and others added 4 commits May 18, 2026 10:28
One coherent 2026-05-18 record covering the k9iser-mcp feature
(cartridge, unified transaction-gated adapter, boj-rest SSE,
ADR-0004 doc reconciliation) and the dogfood-gate.yml CI root-cause
fix. Keeps human + machine state consistent — no half-logged PR.

Refs #73

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath
hyperpolymath merged commit ed08e35 into main May 18, 2026
13 of 21 checks passed
@hyperpolymath
hyperpolymath deleted the feat/k9iser-mcp-cartridge branch May 18, 2026 21:00
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 29 issues detected

Severity Count
🔴 Critical 18
🟠 High 4
🟡 Medium 7

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Stale AI session file -- delete",
    "type": "stale",
    "file": "GEMINI.md",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "medium"
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Python file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/.github/scripts/validate-eclexiaiser.py",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/sanctify-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/academic-workflow-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/fireflag-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/ephapax-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/boj-server/boj-server/cartridges/bofig-mcp/adapter/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants